package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOperation {
    @Override
    public void work(BookList booklist) {
        System.out.println("借阅图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借阅的图书名称：");
        String name = scanner.nextLine();
        int currentSize = booklist.getUserSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getBook(i);
            if (book.getName().equals(name)) {
                System.out.println("该书已经被借出！");
            } else {
                book.setBorrowed(true);
            }
            return;
        }
        System.out.println("没有你要借阅的图书！");
    }

}

